<!doctype html>
<html>
<head>
<title>系统配置</title>
    <?php $this->load->module('admin/index/page_header');?>
<link rel="stylesheet" type="text/css" href="<?php echo URLPRE;?>static/public/Lib/webuploader/webuploader.css">
<!--引入JS-->
<script type="text/javascript" src="<?php echo URLPRE;?>static/public/Lib/webuploader/webuploader.js"></script>

</head>
<body>

<div class="wrap">
    <div id="home_toptip"></div>
    <div class="table_full">
	    <form class="formvalidate" action="<?php echo $form_post;?>" method="post">
	    <div class="h_a">编辑网站信息</div>
		<div class="nav">
			<ul class="cc tab" id="conf_menu">
				<li class="current" id="general_conf"><a href="javascript:void(0);">基本信息</a></li>
				<li id="mail_conf"><a href="javascript:void(0);">邮箱设置</a></li>
				<li id="attach_conf"><a href="javascript:void(0);" style="display: none">附件设置</a></li>
<!--				<li id="watermark_conf"><a href="javascript:void(0);">图片水印设置</a></li>-->
                <li id="sms_conf"><a href="javascript:void(0);">短信设置</a></li>
                <li id="pay_conf"><a href="javascript:void(0);">支付设置</a></li>
                <li id="extend_conf"><a href="javascript:void(0);" style="display: none">扩展信息</a></li>
<!--                <li id="auth_conf"><a href="javascript:void(0);">分销站点</a></li>-->
                <li id="seo_conf"><a href="javascript:void(0);">SEO设置</a></li>
                <li id="gaoji_conf"><a href="javascript:void(0);">高级设置</a></li>
			</ul>
		</div>
	    <div class="table_full">
            <?php $this->load->view('shopconfig/config_jiben');?>
            <?php $this->load->view('shopconfig/config_youxiang');?>
            <?php $this->load->view('shopconfig/config_duanxin');?>
            <?php $this->load->view('shopconfig/config_shuiyin');?>
            <?php $this->load->view('shopconfig/config_fujian');?>
            <?php $this->load->view('shopconfig/config_zhifu');?>
            <?php $this->load->view('shopconfig/config_kuozhan');?>
            <?php $this->load->view('shopconfig/config_gaoji');?>
            <?php $this->load->view('shopconfig/config_seo');?>
	    </div>
	    <div class="btn_wrap">
	        <div class="btn_wrap_pd">
                <input type="hidden" name="other[sid]" value="<?php echo $sid;?>" />
	            <button type="submit" class="btn btn_submit J_ajax_submit_btn">提交</button>
	        </div>
	    </div>
	    </form>
    </div>
</div>
<script type="text/javascript">
    var district_url = '<?php echo site_url('admin/api/city_fetch/?id=')?>';
    _showdistrict(['continent', 'country', 'province', 'city','district'], 2, 40002, [<?php echo $row['siteprovince']['value'];?>, <?php echo $row['sitecity']['value'];?>,<?php echo $row['sitedistrict']['value'];?>]);
    upload_image_2("<?php echo site_url('admin/shopconfig/save_logo')?>",'filePicker','face_image','logo_box');
    upload_image_2("<?php echo site_url('admin/shopconfig/save_wx_qr')?>",'wxfilePicker','face_image','wx_box');
    upload_image_2("<?php echo site_url('admin/shopconfig/save_wb_qr')?>",'wbfilePicker','face_image','wb_box');
    upload_image_2("<?php echo site_url('admin/shopconfig/save_ico')?>",'icoPicker','face_image','ico_box');

    upload_file("<?php echo site_url('admin/shopconfig/save_unionpay_cert');?>",'pfxPicker','pfx_path');
    upload_file("<?php echo site_url('admin/shopconfig/save_unionpay_cert');?>",'cerPicker','cer_path');

    $(function(){

        layer_click();
        span_click();

    //水印位置
        $('#J_locate_list > li > a').click(function(e){
            e.preventDefault();
            var $this = $(this);
            $this.parents('li').addClass('current').siblings('.current').removeClass('current');
            $('#J_locate_input').val($this.data('value'));
        });


        /**
         * tab 短信接口标签切换
         */
        $('#sms_config_sec li').click(function(){
            $(this).closest('#sms_config_sec').find('li').removeClass('current');
            $(this).addClass('current');
            var id = $(this).attr('id')+'ig';
            $("form .tab_label_sec_sms").hide();
            $('#'+id).show();
        });

        /**
         * tab 支付接口标签切换
         */
        $('#conf_menu_sec li').click(function(){
            $(this).closest('#conf_menu_sec').find('li').removeClass('current');
            $(this).addClass('current');
            var id = $(this).attr('id')+'ig';
            $("form .tab_label_sec").hide();
            $('#'+id).show();
        });

    });


    function layer_click(){

        $('#sel_sites').unbind('click').bind('click',function(){
            var title = $(this).attr('title');
            var data_uri = $(this).attr('data-uri');
            $.dialog.open(data_uri,{
                id:'layer',
                title:'选择分销站点',
                padding:'',
                resize: true,
                drag: true,
                width:'80%',
                height:'80%',
                zIndex:'100',
                fixed: true,
                ok:function(){

                    var iframe = this.iframe.contentWindow;
                    if (!iframe.document.body) {
                        alert("iframe loading")
                        return false;
                    };
                    var cont = iframe.document;

                    var sids = $("input[name='Form[dis_sites]']").val();
                    var chenked=$("input[name='site']:checked",cont).val([]);
                    var names = "";
                    for(var i=0;i<chenked.length;i++){
                        names += chenked[i].value +",";
                    }
                    var data = 'sids='+sids+','+names;
                    $.ajax({
                        type:"POST",
                        url:"<?php echo site_url('admin/shopconfig/sel_list')?>",
                        data:data,
                        success:function(result){
                            $("#dis_list").html(result.content);
                            $("input[name='Form[dis_sites]']").val(result.sids);
                            span_click();
                        }
                    });


                },
                cancel:function(){
                }
            });
        });

        $('#sel_citys').unbind('click').bind('click',function(){

            var cityids = '';
            var names ='';
            var title = $(this).attr('title');
            var data_uri = $(this).attr('data-uri');
            $.dialog.open(data_uri,{
                id:'layer',
                title:'选择站点出发城市',
                padding:'',
                resize: true,
                drag: true,
                width:'80%',
                height:'80%',
                zIndex:'100',
                fixed: true,
                ok:function(){

                    var iframe = this.iframe.contentWindow;
                    if (!iframe.document.body) {
                        alert("iframe loading")
                        return false;
                    };
                    var cont = iframe.document;
                    $('.mb10',cont).each(function(){
                        var val_id = $(this).find('select:eq(3)').val();
                        if(val_id=='-1')
                        {
                           return false;

                        }else{
                            cityids += val_id +",";
                        }
                    })


                   var data = 'cityids='+cityids;
                    $.ajax({
                        type:"POST",
                        url:"<?php echo site_url('admin/shopconfig/sel_depart_list')?>",
                        data:data,
                        success:function(result){
                            $("#depart_list").html(result.content);
                            $("input[name='Form[depart_citys]']").val(result.cityids);
                            span_click();
                        }
					　　});


                },
                cancel:function(){
                }
            });
        });


        //附属站点设置
        $('#sel_conn_sites').unbind('click').bind('click',function(){
            var title = $(this).attr('title');
            var data_uri = $(this).attr('data-uri');
            $.dialog.open(data_uri,{
                id:'layer',
                title:'选择附属站点',
                padding:'',
                resize: true,
                drag: true,
                width:'80%',
                height:'80%',
                zIndex:'100',
                fixed: true,
                ok:function(){

                    var iframe = this.iframe.contentWindow;
                    if (!iframe.document.body) {
                        alert("iframe loading")
                        return false;
                    };
                    var cont = iframe.document;

                    var sids = $("input[name='Form[conn_sites]']").val();
                    var chenked=$("input[name='site']:checked",cont).val([]);
                    var names = "";
                    for(var i=0;i<chenked.length;i++){
                        names += chenked[i].value +",";
                    }
                    var data = 'sids='+sids+','+names;
                    $.ajax({
                        type:"POST",
                        url:"<?php echo site_url('admin/shopconfig/sel_list')?>",
                        data:data,
                        success:function(result){
                            $("#conn_list").html(result.content);
                            $("input[name='Form[conn_sites]']").val(result.sids);
                            span_click();
                        }
                    });


                },
                cancel:function(){
                }
            });
        });
    }
    function span_click(){
        $("#dis_list .del").unbind('click').bind('click',function(){
            var key = $(this).attr('title');

            var arr = $("input[name='Form[dis_sites]']").val().split(','),index = $.inArray($(this).attr('alt'),arr);
            if(index>-1){
                arr.splice(index,1);
                $(this).closest('span').remove();
            }
            $("input[name='Form[dis_sites]']").val(arr.join(','));
        });


        $("#depart_list .del").unbind('click').bind('click',function(){

            var sitecity = '<?php echo SITECITY ;?>';


            var key = $(this).attr('title');
            var alt = $(this).attr('alt');
            if(alt==sitecity){
                $.dialog.tips('站点所在城市不可以删除');
                return false;
            }

            var arr = $("input[name='Form[depart_citys]']").val().split(','),index = $.inArray($(this).attr('alt'),arr);
            if(index>-1){
                arr.splice(index,1);
                $(this).closest('span').remove();
            }
            $("input[name='Form[depart_citys]']").val(arr.join(','));
        });

        $("#conn_list .del").unbind('click').bind('click',function(){

            var key = $(this).attr('title');
            var arr = $("input[name='Form[conn_sites]']").val().split(','),index = $.inArray($(this).attr('alt'),arr);
            if(index>-1){
                arr.splice(index,1);
                $(this).closest('span').remove();
            }
            $("input[name='Form[conn_sites]']").val(arr.join(','));
        });
    }
</script>
</body>
</html>